/*************************************************************************
	> File Name: MemExcursionLimiter.h
	> Author: 
	> Mail: 
	> Created Time: 2018/1/22 mon 15:12
	> Version     :
 ************************************************************************/

#ifndef _MEMEXCURSIONLIMITER_H
#define _MEMEXCURSIONLIMITER_H

#define MembraneFilterGainBit  (24)    //Gain expandor Bit number

/******************** Membrane decimate *************************************************** **********/
#define DEC_FILTER_NUM      (2)
#define DEC_TIMES_NUM       (8)
#define DEC_ENABLE_MASK     (0X01)
#define DEC_ENABLE          (0X01)

typedef struct decimateCfg{
    int32_t gain;
    ftCfg_t ft_cfg[DEC_FILTER_NUM];
}decCfg_t;

typedef struct decimateParams{
    int32_t gain;
    ftParams_t ft_params[DEC_FILTER_NUM];
}decParams_t;

/********************Membrane decimate   *************************************************** **********/

/********************Membrane Excursion filter  *************************************************** **********/
#define EX_FILTER_NUM (3)

typedef struct ExcursionfilterCfg{
    int32_t gain;
    ftCfg_t ft_cfg[EX_FILTER_NUM];
}exCfg_t;

typedef struct ExcursionfilterParams{
    int32_t gain;
    ftParams_t ft_params[EX_FILTER_NUM];
}exParams_t;
/********************Membrane Excursion filter  *************************************************** **********/

/********************Membrane Excursion Limiter  *************************************************** **********/
typedef struct memExcursionLimiterCfg{
    uint32_t  moduleEnable;       //enable or disable module Algorithm
    decCfg_t dec_cfg;
    exCfg_t ex_cfg;
    peakDetCfg_t pd_cfg;
    curveCfg_t gcur_cfg;    //gain curve configuration
    smoothCfg_t gs_cfg;     //gain smooth configuration
}memExLimiterCfg_t;

typedef struct memExcursionLimiterParams{
    uint32_t moduleEnable;
    decParams_t dec_params;
    exParams_t ex_params;
    peakDetParams_t pd_params;
    curveParams_t gcur_params;
    smoothParams_t gs_params;
}memExLimiterParams_t;
/********************Membrane Excursion Limiter  *************************************************** **********/

//Excursion Limiter process
void memExLimiterProcess(int32_t *data,memExLimiterCfg_t *cfg,uint16_t dataCnt);
//Get Excursion Limiter  Parameter
int memExLimiterGetParams(memExLimiterCfg_t *cfg,memExLimiterParams_t *params,int32_t *threshold);
//Set Excursion Limiter  Parameter
int memExLimiterSetParams(memExLimiterCfg_t *cfg,memExLimiterParams_t *params,int32_t threshold);
//Init Excursion Limiter
int memExLimiterInit(memExLimiterCfg_t *cfg);
//Reset Excursion Limiter
int memExLimiterReset(memExLimiterCfg_t *cfg);


#endif
